package com.hl.wuyeguanliIDEA.web;


import com.hl.wuyeguanliIDEA.pojo.EventReminder;
import com.hl.wuyeguanliIDEA.pojo.UserScheduleShiftDTO;
import com.hl.wuyeguanliIDEA.service.UserService;
import com.hl.wuyeguanliIDEA.util.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hl.wuyeguanliIDEA.pojo.User;
import com.hl.wuyeguanliIDEA.util.R;
import java.util.List;


@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/selectAll")
    public ResponseEntity<List<UserScheduleShiftDTO>> selectAll() {
        List<UserScheduleShiftDTO> userScheduleShiftDTOS = userService.selectAll();
        return new ResponseEntity<>(userScheduleShiftDTOS, HttpStatus.OK);
    }

    @GetMapping("/schedule-shift")
    public ResponseResult<List<UserScheduleShiftDTO>> getUserScheduleShiftInfo() {
        List<UserScheduleShiftDTO> data = userService.getUserScheduleShiftInfo();
        return ResponseResult.success(data);
    }

    @RequestMapping("/selectUser")
    public List<User> selectUser(User c1) {
        return userService.selectUser(c1);
    }

    @RequestMapping("/selectUserPart")
    public List<User> selectUserPart(User c1) {
        return userService.selectUserPart(c1);
    }

    @RequestMapping("/updateId")
    public int updateId(User c1) {
        return userService.updateId(c1);
    }

    @RequestMapping("/addUser")
    public R insert(User user) {
        int num = userService.insert(user);
        if (num > 0) {
            return R.success(user);
        } else {
            return R.fail();
        }
    }

}
